package com.fr.report.core;

import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.base.core.BaseCoreConstants;
import com.fr.base.core.GraphHelper;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.painter.AbstractPainter;
import java.awt.Graphics;
import java.awt.Image;
import java.io.ByteArrayInputStream;
import java.io.IOException;

public class UploadedImage extends AbstractPainter
{
  private byte[] bytes;
  private transient Image image;

  public UploadedImage(byte[] paramArrayOfByte)
  {
    this.bytes = paramArrayOfByte;
    readImage();
  }

  private void readImage()
  {
    if (this.image != null)
      return;
    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(this.bytes);
    try
    {
      this.image = BaseUtils.readImage(localByteArrayInputStream);
      localByteArrayInputStream.close();
    }
    catch (IOException localIOException)
    {
      this.image = BaseCoreConstants.getDefaultImage();
    }
  }

  public byte[] getBytes()
  {
    return this.bytes;
  }

  public void setBytes(byte[] paramArrayOfByte)
  {
    this.bytes = paramArrayOfByte;
  }

  public Image getImage()
  {
    readImage();
    return this.image;
  }

  public void paint(Graphics paramGraphics, int paramInt1, int paramInt2, Style paramStyle)
  {
    GraphHelper.paintImage(paramGraphics, paramInt1, paramInt2, getImage(), paramStyle, paramStyle.getImageLayout(), -1, -1);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}